<?php


namespace app\api\controller\v1;


use app\common\controller\UserBaseController;
use app\api\model\CityModel;
use app\api\model\ServiceAreaModel;
use common;
use ApiOper;
use think\Db;

class CityController extends UserBaseController
{

    function addAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'city_id' => 'string',
            'name' => 'string',
            'remark' => 'string',
            'coordinates' => 'polygon',
            'coordinate' => 'floatarray',
            'price_rule' => 'array',
            'admin_name' => 'string',
            'admin_phone' => 'string',
            'admin_idcno' => 'string',
        ];

        $this->check_params();
        $this->check_token();

        $city_id = $this->argv['city_id'];
        if (is_numeric($city_id) && strlen($city_id) != 6) {
            $this->throw_myexception(X_ERROR, "城市编码必须为六位数字！");
        }

        $city_exist = (new CityModel())->query_info($city_id);
        if (!empty($city_exist)) {
            $this->throw_myexception(X_ERROR, "城市编码已存在！");
        }


        $city_info = [
            'id' => $city_id,
            'name' => $this->argv['name'],
            'remark' => $this->argv['remark'],
            'coordinates' => $this->argv['coordinates'],
            'coordinate' => $this->argv['coordinate'],
            'admin_name' => $this->argv['admin_name'],
            'admin_phone' => $this->argv['admin_phone'],
            'admin_idcno' => $this->argv['admin_idcno'],
        ];

        $this->resp['info'] = (new CityModel())->add($city_info);

        return $this->ret_resp();
    }

    function updateAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'city_id' => 'string',
            'coordinates' => 'polygon',
            'coordinate' => 'optfloatarray',
            'price_rule' => 'optarray',
            'remark' => 'optstring',
        ];

        $this->check_params();
        $this->check_token();

        (new CityModel())->update_city($this->argv['city_id'], $this->argv);

        return $this->ret_resp();
    }

    function svcasAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'city_id' => 'optstring',
        ];


        $this->check_params();
        $this->check_token();

        $city_id = null;
        if (isset($this->argv['city_id'])) {
            $city_id = $this->argv['city_id'];
        }

        $this->resp['list'] = (new ServiceAreaModel())->get_list($city_id, [], 0, 100);

        return $this->ret_resp();
    }

    function listAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'pno' => 'optint',
            'psize' => 'optint',
        ];

        $this->check_params();
        $this->check_token();

        $this->resp['list'] = (new CityModel())->query_all($this->argv['pos'], $this->argv['limit']);
        $this->resp['total'] = count($this->resp['list']);

        return $this->ret_resp();
    }


    function fencesAction()
    {
        $this->paramlist = [
            'city_id' => 'optstring',
        ];

        $this->check_params();
        $this->check_token();

        $condition = [
            'state' => 0,
        ];
        $svcas = (new ServiceAreaModel())->get_list($this->city_id, $condition, 0, 2000);
        $parks = (new ParkModel())->get_list($this->city_id, $condition, 0, 2000);
        $npas = (new NPAModel())->get_list($this->city_id, $condition, 0, 2000);

        $this->resp['svcas'] = $svcas;
        $this->resp['parks'] = $parks;
        $this->resp['npas'] = $npas;
    }

    function object_nearbyAction()
    {
        $this->paramlist = [
            // 'city_id' => ['optstring', null],
            'coordinate' => 'floatarray',
            'flag' => 'optint',
        ];

        $this->check_params();

        //$this->check_token();
        $svcas = null;
        if (isset($this->argv['city_id'])) {
            $svcas = (new ServiceAreaModel())->get_list($this->argv['city_id'], [], 0, 10);
        }

        if (empty($svcas)) {
            $svcas = (new ServiceAreaModel())->query_list_near($this->argv['coordinate']);
        }


        $svca = null;
        foreach ($svcas as $e) {
            if (isset($e['city_id'])) {
                $svca = $e;
            }
        }

        $city_id = null;
        if (!empty($svcas)) {
            $city_id = $svca['city_id'];
        }
        $this->resp['city_id'] = $city_id;
        $this->resp['svcas'] = $svcas;
        if ($city_id) {
            $this->resp['npas'] = (new NPAModel())->query_list_near($city_id, $this->argv['coordinate']);
            $this->resp['parks'] = (new ParkModel())->query_list_near($city_id, $this->argv['coordinate']);

            $cd = [
                //'health_state' => 0,
                'battery_level' => ['$gt' => 5],
                'bus_state' => 0,
            ];

            $bikes = BikeModel::instance()->query_list_nearby($city_id, $this->argv['coordinate'], 500, $cd);
            $this->resp['bikes'] = $bikes;
        }
    }

    function city_object_nearbyAction()
    {
        $this->paramlist = [
            'city_id' => 'optstring',
            'coordinate' => 'floatarray',
            'flag' => 'int',
        ];

        $FLAG_SERVICE = 1;
        $FLAG_PARK = 2;
        $FLAG_NPA = 4;
        $FLAG_WH = 8;
        $FLAG_BIKE = 16;
        $FLAG_ALL = $FLAG_SERVICE | $FLAG_PARK | $FLAG_NPA | $FLAG_BIKE;

        $this->check_params();
        $this->check_token();
        $city_id = $this->city_id;

        if ($this->argv['flag'] & $FLAG_SERVICE) {
            $cd = [
                'state' => 0,
            ];
            $this->resp['svcas'] = (new ServiceAreaModel())->get_list($city_id, $cd, 0, 10);
        }

        if ($this->argv['flag'] & $FLAG_PARK) {
            $this->resp['parks'] = (new ParkModel())->query_list_near($city_id, $this->argv['coordinate']);
        }
        if ($this->argv['flag'] & $FLAG_NPA) {
            $this->resp['npas'] = (new NPAModel())->query_list_near($city_id, $this->argv['coordinate']);
        }

        if ($this->argv['flag'] & $FLAG_WH) {
            $this->resp['whs'] = (new WarehouseModel())->query_list($city_id, ['state' => 0], 0, 10);
        }

        if ($this->argv['flag'] & $FLAG_BIKE) {
            $cd = [
                'health_state' => 0,
                // 'battery_level' => ['$gt' => 5],
                // 'bus_state' => 0,
            ];

            $bikes = BikeModel::instance()->query_list_nearby($city_id, $this->argv['coordinate'], 1000, $cd);
            $this->resp['bikes'] = $bikes;
        }
    }

    function heatmapAction()
    {
        $this->paramlist = array(
            'token' => 'string',
            'tag' => ['optint', 0],
        );

        $this->check_params();
        $this->check_token();

        $tag = $this->argv['tag'];

        list($order_heat_map, $order_rate_map) = (new BikeIdleTimeMap())->get_heatmap($this->city_id, $tag);
        $bike_heat_map = (new BikeDistMapNew())->heatmap($this->city_id, $tag);
        $bike_code_scaned_heat_map = (new BikeCodeScanDistMapNew())->heatmap($this->city_id, $tag);

        $this->resp['order_heat_map'] = $order_heat_map;
        $this->resp['bike_heat_map'] = $bike_heat_map;
        $this->resp['bike_code_scaned_heat_map'] = $bike_code_scaned_heat_map;
    }


    function monitorAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'start_time' => 'optdatetime',
            'end_time' => 'optdatetime',
        ];


        $this->check_params();
        $this->check_token();

        $start_time = $this->argv['start_time'];
        $end_time = $this->argv['end_time'];

        $this->resp['bike_stat'] = (new BikeModel())->analyze($this->city_id);
        $this->resp['user_growth'] = (new StatModel())->daily_user_growth_list($this->city_id, $start_time, $end_time);
        $this->resp['user_order_growth'] = (new StatModel())->daily_user_order_growth_list($this->city_id, $start_time, $end_time);
        $this->resp['user_scan_qdcode'] = (new StatModel())->daily_user_scan_qdcode_list($this->city_id, $start_time, $end_time);
        $this->resp['user_scan_qdcode_invalid'] = (new StatModel())->daily_user_scan_qdcode_invalid_list($this->city_id, $start_time, $end_time);
        $this->resp['user_order_amount_growth'] = (new StatModel())->user_ride_order_amount_weekly($this->city_id, $start_time, $end_time);

        $this->resp['user_charge_order_amount_grouth'] = (new StatModel())->user_charge_order_amount_weekly($this->city_id, $start_time, $end_time);
        $this->resp['bike_count_daily'] = (new StatModel())->bike_count_weekly($this->city_id, $start_time, $end_time);
        $this->resp['weath'] = (new StatModel())->analyze_wealth($this->city_id, $start_time, $end_time);
    }

    const MONITOR_ACL_TOTAL = '/city/monitorv2/total';
    const MONITOR_ACL_TOMONTH = '/city/monitorv2/tomonth';
    const MONITOR_ACL_TOTAY = '/city/monitorv2/today';

    function monitorv2Action() {
        $this->paramlist = [
            'token' => 'string',
            'start_time' => 'optdatetime',
            'end_time' => 'optdatetime',
            'city' => 'optstring',
            'total' => ['optint', 0],
            'daily' => ['optint', 0],
            'today' => ['optint', 0],
            'tomonth' => ['optint', 0],
        ];

        $this->check_params();
        $this->check_token();

        $start_time = $this->argv['start_time'];
        $end_time = $this->argv['end_time'];

        // $end_time = date('Y-m-d');
        // $start_time = date('Y-m-d', strtotime("-2 day"));

        $city_id = $this->city_id;
        if (!empty($this->argv['city'])) {
            $city_id = $this->argv['city'];
            if ($city_id == 'ALL') {
                $city_id = null;
            }
        }

        $l = [];
        if ($this->argv['total']) {
            $m = (new StatModelNew())->city_monitor_total($city_id);
            $this->resp = array_merge($this->resp, $m);
        }
        if ($this->argv['today']) {
            $this->resp['bike_stat'] = (new BikeModel())->analyze($city_id);
            $m = (new StatModelNew())->city_monitor_day($city_id, date('Y-m-d'));
            $this->resp = array_merge($this->resp, $m);
        }

        if ($this->argv['daily']) {
            $m = (new StatModelNew())->city_monitor_daily($city_id, $start_time, $end_time);
            $this->resp = array_merge($this->resp, $m);
        }

        if ($this->argv['tomonth']) {
            $m = (new StatModelNew())->city_monitor_tomonth($city_id);
            $this->resp = array_merge($this->resp, $m);
        }
    }

    function cities_monitorAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'start_time' => 'optdatetime',
            'end_time' => 'optdatetime',
        ];

        $cities = (new CityModel())->query_all(0, 100);

        $city_stat_map = ['ALL' => [
            'bike_count' => 0,
            'user_count_stat_daily' => [],
            'ride_order_count_stat_daily' => [],
            'user_scan_qdcode_count_stat_daily' => [],
            'ride_order_amount_tomonth' => 0,
            'user_charge_order_amount_tomonth' => 0,
            'user_refund_order_amount_tomonth' => 0,
            'user_membership_order_amount_tomonth' => 0,
            'user_count_total' => 0,
            'user_count_tomonth' => 0,
            'user_ride_count_tomonth' => 0,
            'user_ride_order_amount_total' => 0,
            'ride_order_amount_tomonth' => 0,
            'user_charge_order_amount_total' => 0,
            'user_membership_order_amount_total' => 0,
            'bike_count_daily' => [],
        ]];


        $start_time = $this->argv['start_time'];
        $end_time = $this->argv['end_time'];

        $dates = [];
        for ($i = 0; $i < 8; $i++) {
            $dates[] = date('Y-m-d', strtotime("-{$i} day"));
        }

        foreach ($dates as $d) {
            $city_stat_map['ALL']['user_count_stat_daily'][$d] = 0;
            $city_stat_map['ALL']['ride_order_count_stat_daily'][$d] = 0;
            $city_stat_map['ALL']['user_scan_qdcode_count_stat_daily'] [$d] = 0;
            $city_stat_map['ALL']['bike_count_daily'] [$d] = 0;
        }

        foreach ($cities as $city) {
            $city_stat_map [$city['name']] = [];
        }
        foreach ($cities as $city) {
            $city_id = $city['id'];
            $city_name = $city['name'];
            $city_stat_map[$city_name]['bike_count'] = (new BikeModel())->query_bike_count($city_id);
            $city_stat_map[$city_name]['user_count_stat_daily'] = (new StatModel())->daily_user_growth_list($city_id,$start_time, $end_time);
            $city_stat_map[$city_name]['ride_order_count_stat_daily'] = (new StatModel())->daily_user_order_growth_list($city_id, $start_time, $end_time);
            $city_stat_map[$city_name]['user_scan_qdcode_count_stat_daily'] = (new StatModel())->daily_user_scan_qdcode_list($this->city_id,$start_time, $end_time);
            foreach ($dates as $d) {
                $city_stat_map['ALL']['user_count_stat_daily'][$d] += $city_stat_map[$city_name]['user_count_stat_daily'][$d];
                $city_stat_map['ALL']['ride_order_count_stat_daily'][$d] += $city_stat_map[$city_name]['ride_order_count_stat_daily'][$d];
                $city_stat_map['ALL']['user_scan_qdcode_count_stat_daily'][$d] += $city_stat_map[$city_name]['user_scan_qdcode_count_stat_daily'][$d];
            }
            $city_stat_map['ALL']['bike_count'] += $city_stat_map[$city_name]['bike_count'];
        }
        foreach ($cities as $city) {
            $city_id = $city['id'];
            $city_name = $city['name'];
            $city_stat_map[$city_name]['ride_order_amount_tomonth'] = (new StatModel())->user_ride_order_amount_tomonth_sum($city_id);
            $city_stat_map[$city_name]['user_charge_order_amount_tomonth'] = (new StatModel())->user_charge_order_amount_tomonth_sum($city_id);
            $city_stat_map[$city_name]['user_refund_order_amount_tomonth'] = (new StatModel())->user_refund_order_amount_tomonth_sum($city_id);
            $city_stat_map[$city_name]['user_membership_order_amount_tomonth'] = (new StatModel())->user_membership_order_amount_tomonth_sum($city_id);
            $city_stat_map['ALL']['ride_order_amount_tomonth'] += $city_stat_map[$city_name]['ride_order_amount_tomonth'];
            $city_stat_map['ALL']['user_charge_order_amount_tomonth'] += $city_stat_map[$city_name]['user_charge_order_amount_tomonth'];
            $city_stat_map['ALL']['user_refund_order_amount_tomonth'] += $city_stat_map[$city_name]['user_refund_order_amount_tomonth'];
            $city_stat_map['ALL']['user_membership_order_amount_tomonth'] += $city_stat_map[$city_name]['user_membership_order_amount_tomonth'];
        }

        foreach ($cities as $city) {
            $city_id = $city['id'];
            $city_name = $city['name'];
            $city_stat_map[$city_name]['user_count_total'] = (new StatModel())->user_count_total($city_id);
            $city_stat_map[$city_name]['user_count_tomonth'] = (new StatModel())->user_count_tomonth_sum($city_id);
            $city_stat_map[$city_name]['user_ride_count_tomonth'] = (new StatModel())->user_ride_count_tomonth_sum($city_id);
            $city_stat_map[$city_name]['user_ride_order_amount_total'] = (new StatModel())->user_ride_order_amount_total($city_id);
            $city_stat_map[$city_name]['user_charge_order_amount_total'] = (new StatModel())->user_charge_order_amount_total($city_id);
            $city_stat_map[$city_name]['user_membership_order_amount_total'] = (new StatModel())->user_membership_order_amount_total($city_id);

            $city_stat_map['ALL']['user_count_total'] += $city_stat_map[$city_name]['user_count_total'];
            $city_stat_map['ALL']['user_count_tomonth'] += $city_stat_map[$city_name]['user_count_tomonth'];
            $city_stat_map['ALL']['user_ride_count_tomonth'] += $city_stat_map[$city_name]['user_ride_count_tomonth'];
            $city_stat_map['ALL']['user_ride_order_amount_total'] += $city_stat_map[$city_name]['user_ride_order_amount_total'];
            $city_stat_map['ALL']['user_charge_order_amount_total'] += $city_stat_map[$city_name]['user_charge_order_amount_total'];
            $city_stat_map['ALL']['user_membership_order_amount_total'] += $city_stat_map[$city_name]['user_membership_order_amount_total'];
        }

        foreach ($cities as $city) {
            $city_id = $city['id'];
            $city_name = $city['name'];
            $city_stat_map[$city_name]['bike_count_daily'] = (new StatModel())->bike_count_weekly($city_id);
            foreach ($dates as $d) {
                $city_stat_map['ALL']['bike_count_daily'][$d] += $city_stat_map[$city_name]['bike_count_daily'][$d];
            }
        }

        $this->resp['city_stat_map'] = $city_stat_map;
    }


    function flush_object_to_mongoAction()
    {
        $this->paramlist = [
            'city_id' => 'string',
        ];

        $this->check_params();

        $city_id = $this->argv['city_id'];

        himongo::db()->delete(['city_id' => $city_id]);

        $arr = (new ServiceAreaModel())->get_list($city_id, [], 0, 10000);
        foreach ($arr as $e) {
            try {
                (new ServiceAreaModel())->save_to_mongo($city_id, $e['id']);
            } catch (Exception $ex) {
                hilog::error("save SVC error", $e, $ex->getMessage());
            }
        }
        $arr = (new NPAModel())->get_list($city_id, [], 0, 10000);
        foreach ($arr as $e) {
            try {
                (new NPAModel())->save_to_mongo($city_id, $e['id']);
            } catch (Exception $ex) {
                hilog::error("save  NPA error", $e, $ex->getMessage());
            }
        }
        $arr = (new ParkModel())->get_list($city_id, [], 0, 10000);
        foreach ($arr as $e) {
            try {
                (new ParkModel())->save_to_mongo($city_id, $e['id']);
            } catch (Exception $ex) {
                hilog::error("save Park error", $e, $ex->getMessage());
            }
        }
        $arr = (new BikeModel())->get_list($city_id, [], 0, 10000);
        foreach ($arr as $e) {
            try {
                (new BikeModel())->save_to_mongo($e);
            } catch (Exception $ex) {
                hilog::error("save Bike error", $e, $ex->getMessage());
            }
        }
        $arr = (new WarehouseModel())->query_list($city_id, [], 0, 10000);
        foreach ($arr as $e) {
            try {
                (new WarehouseModel())->save_to_mongo($city_id, $e['id']);
            } catch (Exception $ex) {
                hilog::error("save Warehouse error", $e, $ex->getMessage());
            }
        }
    }

    function test_mongoAction()
    {
        $cities = (new CityModel())->query_all_online(0, 100);
        foreach ($cities as $city) {
            $city_id = $city['id'];
            $city_name = $city['name'];

            $id = (new CityAnalyzeModel())->analyze($city_id,$city_name);
            (new CityAnalyzeModel())->analyze_person($city_id,$id);
        }
    }

    function infoAction()
    {
        $this->paramlist = [
            'token' => 'string',
            'id' => 'string',
        ];

        $this->check_params();
        $this->check_token();
        $this->resp['info'] = (new CityModel())->query_info($this->argv['id']);
    }

    function fix_order_amountAction()
    {
        $this->paramlist = [
            'pno' => 'int',
            'psize' => 'int',
        ];

        $this->check_params();


        $selectlist = [
            'id' => 'string',
            'fee_info' => 'array',
            'original_amount' => 'int',
            'paid_amount' => 'int'
        ];

        $pos = $this->argv['pos'];
        $limit = $this->argv['limit'];
        $st = "select " . implode(',', array_keys($selectlist)) . " from tb_user_ride_order limit {$pos}, $limit";


        $result = hisql::db()->query($st, []);
        $rows = $result->fetchAll(Phalcon\Db::FETCH_ASSOC);
        foreach ($rows as $row) {
            $info = common::sql_row($selectlist, $row);
            $fee_info = $info['fee_info'];
            $total = $fee_info['basic_fee'] + $fee_info['mile_fee'] + $fee_info['duration_fee'] + $fee_info['npa_fee'] + $fee_info['osvc_fee'] - $fee_info['coupon_fee'];
            if ($fee_info['total'] != $total || $total != $info['original_amount']) {
                $fee_info['total'] = $total;
                $data = [
                    'fee_info' => $fee_info,
                    'original_amount' => $total,
                    'paid_amount' => $total,
                ];
                $where = ['id' => $info['id']];

                // hilog::debug($data, $where);
                hisql::update('tb_user_ride_order', $data, $where);
            }
        }
        $this->resp['count'] = count($rows);
    }

    function noticeAction()
    {
        $this->paramlist = array(
            'coordinate' => ['optarray', null],
        );

        $this->check_params();

        $city_id = null;
        if (isset($this->argv['coordinate'])) {
            $svcas = (new ServiceAreaModel())->query_list_near($this->argv['coordinate']);
            if (!empty($svcas)) {
                $city_id = $svcas[0]['city_id'];
            }
        }
        if ($city_id && $city_id == '350001') {
            // $this->resp['notice_url'] = "https://res.ddebike.com/tcgf.png";
        } else {
        }

        $this->resp['notice_url'] = 'https://res.ddebike.com/weekend.jpg';
    }

    function set_wealthAction()
    {
        $this->paramlist = [
        ];

        $this->check_params();

        $cities = (new CityModel())->query_all(0, 100);

        foreach ($cities as $city) {
            $city_id = $city['id'];
            $city_name = $city['name'];
            $city_wealth = common::get_wealth($city_name);
            (new StatModel())->analyze_setwealth($city_id, $city_name,$city_wealth);
        }
    }

    function flush_bike_to_UmaleAction(){
        $this->paramlist = [
            'city_id' => 'string',
        ];

        $this->check_params();

        $city_id = $this->argv['city_id'];

//        $arr = (new BikeModel())->get_list($city_id, [], 0, 1000);
//        foreach ($arr as $e) {
//            try {
//                (new UMaleModel())->bike_Info($e,1);
//            } catch (Exception $ex) {
//                hilog::error("save Bike error", $e, $ex->getMessage());
//            }
//        }

        $e = (new BikeModel())->get_info_by_sn('10011655');
        (new UMaleModel())->bike_postInfo($e);
    }

    //获取日志
    function get_city_daily_reportAction(){
        $this->paramlist = [
            'token' => 'string',
            'city_id' => 'optstring',       //城市id，当城市id不填时，就是获取所有城市的日常
            'start_time' => 'string',       //以天为单位
            'end_time' => 'string',         //以天为单位
        ];

        $this->check_params();
        $this->check_token();


        $city_id = null;

        if (isset($this->argv['city_id'])){
            $city_id = $this->argv['city_id'];
        }

        if($city_id == 'ALL'){
            $city_id = null;
        }


        $pos = $this->argv['pos'];
        $limit = $this->argv['limit'];


        $list = (new  CityAnalyzeModel())->query_list($city_id,$this->argv['start_time'],$this->argv['end_time'],$pos,$limit);
        $this->resp['info'] = $list;
        $this->resp['total'] = hisql::query_count();
    }

    //获取详细信息
    function get_city_person_daily_reportAction(){
        $this->paramlist = [
            'token' => 'string',
            'city_id' => 'string',       //city_id
            'log_id' => 'string',       //具体日报的id
        ];

        $this->check_params();
        $this->check_token();



        $list= (new  CityAnalyzeModel())->get_city_person_daily_report($this->argv['city_id'],$this->argv['log_id'],$this->argv['pos'],$this->argv['limit']);
        $this->resp['info'] = $list;
        $this->resp['total'] = hisql::query_count();
    }

    //设置相关信息
    function set_city_dailydataAction(){
        $this->paramlist = [
            'token' => 'string',
            'city_id' => 'string',       //城市id
            'city_wealth' => 'string',           //天气
            'day_time' => 'string',       //以天为单位
            'bike_col' => 'int',            //城管收车数
            'bike_fault' => 'int',          //事故车
            'url' => 'optstring',           //上传图片可选
            'remark' => 'optstring',        //备注可选
        ];

        $this->check_params();
        $this->check_token();


        (new CityAnalyzeModel())->set_daily_data($this->argv);      //设置数据
    }


    //招商加盟
    function join_usAction(){
        $this->paramlist = [
            'token' => 'string',
            'city_name' => 'string',
            'user_name' => 'string',
            'user_phone' => 'string',
            'company' => ['optstring',''],
        ];

        $this->check_params();
        $this->check_token();

        if (!common::is_phone($this->argv['user_phone'])){
            $this->throw_myexception(X_ERROR, "不是有效的手机号码！");
        }

        $user_info = ApiOper::instance()->userinfo();
        $data = [
            'id' => IDMan::order_id(),
            'city_name' => $this->argv['city_name'],
            'user_phone' => $this->argv['user_phone'],
            'user_name'  => $this->argv['user_name'],
            'user_comp' => $this->argv['company'],
            'create_time' =>  date('Y-m-d H:i:s'),
            'add_user_id' => $user_info['id'],
            'add_user_name' => $user_info['name']
        ];

        Db::table('tb_join')->insert($data);

        return $this->ret_resp();
    }
}